package com.androidcourse.shounews.Fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.androidcourse.shounews.Activity.MainActivity;
import com.androidcourse.shounews.R;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link BottomFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class BottomFragment extends Fragment implements RadioGroup.OnCheckedChangeListener {
    private RadioGroup radioGroup;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_bottom, container, false);
    }

    @SuppressLint("UseCompatLoadingForDrawables")
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        radioGroup=getActivity().findViewById(R.id.bottom_group_radio);
        radioGroup.setOnCheckedChangeListener(this);
        RadioButton message=getActivity().findViewById(R.id.bottom_news);
        message.setCompoundDrawablesWithIntrinsicBounds(null,getActivity().getDrawable(R.drawable.message_pressed_34),null,null);
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        ((MainActivity)getActivity()).onCheckedChanged(group,checkedId);
    }
}